package com.unicorn.modual.fts.service.impl;

import com.unicorn.modual.fts.service.FtsService;
import com.unicorn.util.common.FileComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.List;

/**
 * Created by user on 2016/12/3.
 */
@Service
public class FtsServiceImpl implements FtsService {

    @Autowired
    private FileComponent fileCompoment;

    @Override
    public List<File> listFiles(String parentPath) {
        File parentFile=new File(parentPath);
        if(parentFile.exists() && parentFile.isDirectory()) {
            return fileCompoment.listFiles(parentPath);
        }else{
            throw new RuntimeException(parentFile.getAbsolutePath()+"不存在或不是目录");
        }
    }

    @Override
    public List<File> listFiles(File parentFile) {
        if(parentFile.exists() && parentFile.isDirectory()) {
            return fileCompoment.listFiles(parentFile.getAbsolutePath());
        }
        else{
            throw new RuntimeException(parentFile.getAbsolutePath()+"不存在或不是目录");
        }
    }
}
